package GameObjects.Ships.Weapon;

import java.awt.event.ActionListener;
import java.util.ArrayList;

import GUI.BottomPanel;
import GameObjects.InstanceObject;
import GameObjects.Instances.Instances;
import GameObjects.Physics.Position;
import GameObjects.Ships.Ship;
import GameObjects.Ships.ShipObject;
import GameObjects.Ships.Weapon.Bullets.Bullet;
import GameObjects.Ships.Weapon.ShootingTypes.ShootingType;

public abstract class Weapon extends ShipObject
{
	protected final ShootingType shootingType;
	protected double energyCost;
	
	protected InstanceObject target;
	
	public Weapon(Instances instances, Position position, double health, ShootingType shootingType, double energyCost)
	{
		super(instances, position, health);
		this.energyCost = energyCost;
		this.shootingType = shootingType;
	}
	
	@Override
	public void setPanel(ActionListener actionListener, BottomPanel panel)
	{
//		panel.addObjectPanelBottomRight(new WeaponPanel(actionListener, GameScreen.BOTTOM_WIDTH, GameScreen.BOTTOM_HEIGHT));
	}

	@Override
	public boolean tick() 
	{
		shootingType.tick();
		return false;
	}

	
	public ArrayList<Bullet> shoot()
	{
		if(hasHealth())
			return shootingType.fireWeapon(new Position(position));
		else
			return new ArrayList<Bullet>(1);
	}
	
	public double cost()
	{
		return energyCost;
	}
	
	public void target(InstanceObject target)
	{
		this.target = target;
	}
}
